package API.Stream.Practise;

import java.util.ArrayList;
import java.util.Collections;
import java.util.function.Function;
import java.util.stream.Stream;

public class FilterAndTransactionToClass {
    public static void main(String[] args) {
        ArrayList<String> manList = new ArrayList<String>();
        ArrayList<String> womanList = new ArrayList<>();
        Collections.addAll(manList, "Jack,24", "Nick,23", "Black,22", "Mike,24", "Noire,30", "Noha,27");
        Collections.addAll(womanList, "Alic,35", "Anna,36", "Bella,43", "Helen,31", "Lily,35", "Candy,33");
        Stream<String> manStream = manList.stream().
                filter(s -> s.split(",")[0].length() == 4);
        Stream<String> womanStream = womanList.stream().
                filter(s -> s.startsWith("A"));
        Stream<String> mainStream = Stream.concat(manStream, womanStream);
        mainStream.map(
                new Function<String, Actor>() {
                    @Override
                    public Actor apply(String s) {
                        return new Actor(s.split(",")[0], Integer.parseInt(s.split(",")[1]));
                    }
                }
        ).forEach(s -> System.out.println(s));

    }
}
